import { Module } from 'vuex';
import { KeepAliveListState, RootStateTypes } from '@/store/interface';

const keepAliveListModule: Module<KeepAliveListState, RootStateTypes> = {
	namespaced: true,
	state: {
		keepAliveList: [],
	},
	mutations: {
		// 设置路由缓存（name字段）
		getCacheKeepAlive(state, data: Array<string>) {
			state.keepAliveList = data;
		},
	},
	actions: {
		// 设置路由缓存（name字段）
		async setCacheKeepAlive({ commit }, data: Array<string>) {
			commit('getCacheKeepAlive', data);
		},
	},
};

export default keepAliveListModule;
